//PITCH PROGRAM
//CLASS: Bid
//	-determine bids from players and set highest bidder
//BY: ALEX TRACY
public class Bid 
{
	private int highBid = 0; //current high bid out of all the players
	private int highBidder;//current player with high bid
	private int playerToBid;//player whos turn it is to bid
	private int numOfPlayers;//number of players playing
	private Player[] players;
	
	//constructor sets player to bid
	public Bid(int i,Player[] p)
	{
		playerToBid = i;
		numOfPlayers = p.length;
		players = p;
	}//End Constructor
	
	//get the bids for all players
	//if current bid is larger that highBid set
	//the current bid to high bid
	//if no one bid make last player bid 2
	public int getBids()
	{
		highBid = 0;
		int count = 0;
		while (count < numOfPlayers)
		{
			if (players[playerToBid].bid(highBid) > highBid)
			{
				highBid = players[playerToBid].getBid();
				highBidder = playerToBid;
				
			}
			if (highBid == 0 && count == numOfPlayers - 1)
			{
				highBid = 2;
				highBidder = playerToBid;
			}
			incrementBider();
			count++;
		}
		return highBidder;
	}//end getBids
	
	//set high bid to i
	public void setHighBid(int i)
	{
		highBid = i;
	}//End setHighBid
	
	//set highBidder to i
	public void setHighBidPlayer(int i)
	{
		highBidder = i;
	}//end setHighBidPlayer
	
	//set player to bid
	public void setPlayerToBid(int i)
	{
		playerToBid = i;
	}
	
	//increment bidder , if bidder is the
	//size of the bidders - 1 go to beginning
	//of bidder, otherwise increment 1
	private void incrementBider()
	{
		if (playerToBid == numOfPlayers - 1)
			playerToBid = 0;
		else
			playerToBid++;
	}//End incrementBidder
	
}
